<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算属性</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="vue.js"></script>
</head>
<body>
    <div id="root">
        姓：<input type="text" v-model="firstName"><br><br>
        名：<input type="text" v-model="lastName"><br><br>
        姓名watch：<span></span><br><br>
        姓名computed：<span>{{fullNameComp}}</span>
        姓名computed：<span>{{fullNameComp1}}</span>
    </div>
   <script type="text/javascript">
    new Vue({
        el:'#root',
        data: {
            firstName:'张',
            lastName:'三',
            fullName:''
        },
        watch: {
            fullName: {

            }
        },
        computed: {
            fullNameComp: {
                get() {
                 console.log("get被调用了");
                 return this.firstName + '-' + this.lastName
                }
            },
            // 简写形式
            fullNameComp1() {
                return this.firstName + '-' + this.lastName
            }
        }
    })
   </script>
</body>
</html>